import 'package:flutter/material.dart';
import 'package:flutter_pickers/pickers.dart';
import 'package:flutter_pickers/style/picker_style.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Demo"),
      ),
      body: Column(
        children: [
          ElevatedButton(
            onPressed: () {
              Pickers.showDatePicker(
                context,
                mode: DateMode.YMDHMS,
                pickerStyle: PickerStyle(
                  title: const Center(
                    child: Text("标题"),
                  ),
                ),
                onChanged: (res) {
                  print(res);
                },
              );
            },
            child: const Text("日期时间选择器"),
          ),
          ElevatedButton(
            onPressed: () {
              Pickers.showAddressPicker(context);
            },
            child: const Text("地域选择器"),
          ),
        ],
      ),
    );
  }
}
